import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop0018_添加属性流程"
#1.打开后台 登录
firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
#点击商品管理,商品属性,属性分组
time.sleep(1)
DBshopEnterMenu3(firefox,"商品管理","商品属性","属性")
# "1.点击“添加属性”按钮，编写属性分组“好好学习”，属性类型“下拉”，属性名称“天天向上”，排序“255”。

firefox.find_element_by_xpath('//*[@href="/dbshop/admin/goods/attribute/add"]').click()
firefox.find_element_by_xpath('//option[text()="好好学习"]').click()
firefox.find_element_by_xpath('//option[text()="下拉"]').click()
firefox.find_element_by_id('attribute_name').send_keys('天天向上')
firefox.find_element_by_id('attribute_sort').clear()
firefox.find_element_by_id('attribute_sort').send_keys('255')
# 2.点击“保存属性信息”按钮，保存成功。"
firefox.find_element_by_xpath('//button').click()
#断言
try:
    firefox.find_element_by_xpath('//td[contains(.,"天天向上")]/following-sibling::td[4]/a[1]')
    writeLog("%s 测试通过" % testCase)
except:
    writeLog("%s 测试不通过" % testCase)
    getPhoto(firefox)
firefox.quit()